<template>
  <InlineLayout title-name="审核记录列表">
    <template #header>
      <my-form ref="queryFormRef" v-model:modelValue="queryParams" :model="queryParams" :items-datas="itemsDatas">
        <my-button type="reset" title="重置" @click="resetQuery" />
        <my-button type="search" title="查询" :loading="loading" @click="handleQuery" />
      </my-form>
    </template>

    <!-- <template #titleTools>
      <my-button type="export" title="导出" @click="openClick" />
    </template> -->

    <my-table :columns="columns" :table-data="tableData" style="height: auto">
      <template #examinedataType="scope">
        <span v-if="scope.row.examinedataType === 1">单位信息</span>
        <span v-if="scope.row.examinedataType === 2">人员信息</span>
        <span v-if="scope.row.examinedataType === 3">缴费明细</span>
      </template>
      <template #examineStatus="scope">
        <span v-if="scope.row.examineStatus === 1">审核通过</span>
        <span v-if="scope.row.examineStatus === 2">审核不通过</span>
      </template>
    </my-table>
    <pagination v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
  </InlineLayout>
</template>

<script setup name="Examinedata" lang="ts">
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
import { listExaminedata } from '@/api/yuanshidian/examinedata/index';
const loading = ref(true);
const total = ref(0);

const queryFormRef = ref<ElFormInstance>();
const examinedataFormRef = ref<ElFormInstance>();

const state = reactive({
  title: '',
  queryParams: {
    pageNum: 1,
    pageSize: 10
  },
  itemsDatas: [
    { label: '审核数据ID', prop: 'examinedataId', type: 'input' },
    { label: '审核意见', prop: 'examineRemark', type: 'input' },
    { label: '审核人姓名', prop: 'examineName', type: 'input' },
    { label: '审核时间', prop: 'examineDate', type: 'date' }
  ],
  tableData: [],
  columns: [
    { label: '序号', type: 'index', width: '55', prop: 'index' },
    { label: '审核单位名称', prop: 'dwname', align: 'center' },
    { label: '审核人员姓名', prop: 'ryname', align: 'center' },
    /*{ label: '审核数据ID', prop: 'examinedataId', align: 'center' },*/
    { label: '审核数据类型', prop: 'examinedataType', align: 'center', type: 'custom', slot: 'examinedataType' },
    { label: '审核数据状态', prop: 'examineStatus', align: 'center', type: 'custom', slot: 'examineStatus' },
    { label: '审核意见', prop: 'examineRemark', align: 'center' },
    { label: '审核人姓名', prop: 'examineName', align: 'center' },
    { label: '审核时间', prop: 'examineDate', align: 'center' }
  ]
});
const { itemsDatas, tableData, columns, queryParams, isShow, currentRow, visible, title } = toRefs(state);

/** 查询审核列表列表 */
const getList = async () => {
  loading.value = true;
  const res = await listExaminedata(queryParams.value);
  tableData.value = res.rows;
  total.value = res.total;
  loading.value = false;
};

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.value.pageNum = 1;
  getList();
};

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value?.resetFields();
  handleQuery();
};

/** 导出按钮操作 */
const handleExport = () => {
  proxy?.download(
    'yuanshidian/examinedata/export',
    {
      ...queryParams.value
    },
    `examinedata_${new Date().getTime()}.xlsx`
  );
};

onMounted(() => {
  getList();
});
</script>
